function renderuser() {
    $.ajax({
        url: '/my/user/userinfo',
        success: function (res) {
            if (res.status === 0) {
                let name = res.data.nickname || res.data.username
                $('.username').text(name)
                // 处理头像处理头像*******
                if (res.data.user_pic) {
                    $('.layui-nav-img').attr('src', res.data.user_pic).show()
                    $('.text-avatar').hide()
                } else {
                    let first = name.substr(0, 1).toUpperCase()
                    $('.text-avatar').text(first).css('display', 'inline-block')
                }
            }
        },
    })
}
renderuser()


$('#logout').on('click', function (e) {
    e.preventDefault()
    layer.confirm('确定要退出吗？', function (index) {
        location.href = './login.html'
        localStorage.removeItem('token')
        layer.close(index)
    })
})